package com.purong.purong;

import android.Manifest;

import java.util.List;

/**
 * @author chenzj
 * @Title: PerssionConstants
 * @Description: 类的描述 -
 * @date 2016/6/29 17:27
 * @email admin@chenzhongjin.cn
 */
public class PermissionConstant {
    public static final String[] PERMS_LOCATION = { Manifest.permission.ACCESS_FINE_LOCATION
            ,Manifest.permission.ACCESS_COARSE_LOCATION};
    public static final String[] PERMS_PHOTO = { Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE,
            Manifest.permission.CAMERA};

    public static final String[] PERMS_PHONE_STATE = {
            Manifest.permission.READ_PHONE_STATE};
    public static final String[] PERMS_CHAT = {
            Manifest.permission.RECORD_AUDIO,Manifest.permission.ACCESS_FINE_LOCATION
            ,Manifest.permission.ACCESS_COARSE_LOCATION};
    public static final String[] PERMS_CONTACT = {
            Manifest.permission.READ_CONTACTS};
    public static final String[] PERMS_STORAGE = {
            Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE};
    public static String getPermsName(String perms){
        if (perms.equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)){
            return "写入手机存储权限";
        }else if (perms.equals(Manifest.permission.READ_EXTERNAL_STORAGE)){
            return "读取手机存储权限";
        }else if (perms.equals(Manifest.permission.CAMERA)){
            return "调用摄像头权限";
        }else if (perms.equals(Manifest.permission.READ_PHONE_STATE)){
            return "获取手机信息权限";
        }else if (perms.equals(Manifest.permission.RECORD_AUDIO)){
            return "录音权限";
        }else if (perms.equals(Manifest.permission.ACCESS_FINE_LOCATION)){
            return "GPS定位权限";
        }else if (perms.equals(Manifest.permission.ACCESS_COARSE_LOCATION)){
            return "网络定位权限";
        }else if (perms.equals(Manifest.permission.READ_CONTACTS)){
            return "读取通讯录权限";
        }else {
            return "";
        }
    }
    public static String getPermsName(List<String> permList){
        StringBuffer buffer=new StringBuffer();
        String permName="";
        for (int i = 0; i <permList.size() ; i++) {
            permName=getPermsName(permList.get(i));
            if (permName.equals("")){
                return "部分权限";
            }
            buffer.append(permName);
            if (i!=permList.size()-1){
                buffer.append("、");
            }
        }
        return buffer.toString();

    }
    public static String getPermsName(String[] permArray){
        StringBuffer buffer=new StringBuffer();
        String permName="";
        for (int i = 0; i <permArray.length ; i++) {
            permName=getPermsName(permArray[i]);
            if (permName.equals("")){
                return "部分权限";
            }
            buffer.append(permName);
            if (i!=permArray.length-1){
                buffer.append(",");
            }
        }
        return buffer.toString();

    }
}

